import { TeamParam } from "@/type/team"
import { isCodeMessage } from "../config"

/**
 * @author: 小佘佘🦀
 * @description: 创建团队
 * @param {TeamParam} team
 * */
export const createTeam = async (team: TeamParam) => {

    const param = new URLSearchParams()
    param.append("team_name", team.team_name)
    param.append("email", team.email)
    param.append("emoji", team.emoji + "")

    const response = await fetch(`/api-backend/api/team/add`, {
        method: "POST",
        headers: {
            "content-type": "application/x-www-form-urlencoded",
        },
        mode: "no-cors",
        body: param.toString(),
        redirect: "manual"
    })

    return isCodeMessage(response)
}